import random

import pandas as pd
import xlrd
import os

import warnings
warnings.filterwarnings("ignore")


def start_process(): #get the address data from "省市区邮编区号.csv" data set and randomly generate the address of the shop
    import_data = pd.read_csv(r'C:\Users\寒升\Desktop\电商网站\phoneShop\Create_address\省市区邮编区号.csv', encoding='gb18030')
    data_df= pd.DataFrame({ # create the dataframe
        "code": import_data["code"],
        "province": import_data["province"],
        "city": import_data["city"],
        "area": import_data["area"],
        "area_code": import_data["area_code"],
        "post_code": import_data["post_code"]
    })
    return data_df

def joint_address(data_df):
    data_df["final_address"] = data_df["province"]+data_df["city"]+data_df["area"] # create the final form of address
    return data_df["final_address"]

def return_address(se):
    return se.iloc[random.randint(0,len(se)-2)]# Returns a random address

if __name__ == '__main__':
    df = start_process()
    se1 = joint_address(df)
    for i in range(0,10):
        ad1 = return_address(se1)
        print(ad1)
